package com.szewec.ps.ui.road.facilities.intersection.task;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.MotionEvent;
import android.view.View;
import android.widget.TextView;

import androidx.activity.result.ActivityResult;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;
import com.szewec.ps.R;
import com.szewec.ps.base.BaseActivity;
import com.szewec.ps.base.BaseMediaPickerActivity;
import com.szewec.ps.base.CommonDialog;
import com.szewec.ps.base.Constants;
import com.szewec.ps.base.FileUpload;
import com.szewec.ps.base.ListBaseAdapter;
import com.szewec.ps.base.SuperViewHolder;
import com.szewec.ps.databinding.ActivityIntersectionTaskBinding;
import com.szewec.ps.greenDao.dao.AlbumFile;
import com.szewec.ps.model.PresentValue;
import com.szewec.ps.model.response.ResponseData;
import com.szewec.ps.model.selectmappoint.SelectedPoint;
import com.szewec.ps.model.task.SurveyObjectModel;
import com.szewec.ps.myinterface.CallBackInterface;
import com.szewec.ps.myview.album.AlbumSection;
import com.szewec.ps.myview.toast.bamtoast.BamToast;
import com.szewec.ps.ui.road.facilities.intersection.task.constants.Consts;
import com.szewec.ps.ui.road.facilities.intersection.task.enums.RoadEnums;
import com.szewec.ps.ui.road.facilities.intersection.task.model.EntranceRoad;
import com.szewec.ps.ui.road.facilities.intersection.task.model.GradeCrossing;
import com.szewec.ps.ui.road.facilities.intersection.task.model.RoadHierarchy;
import com.szewec.ps.ui.road.facilities.intersection.task.model.IntersectionTask;
import com.szewec.ps.ui.road.facilities.intersection.task.model.RoundaboutDetail;
import com.szewec.ps.ui.road.facilities.intersection.task.model.SolidCrossing;
import com.szewec.ps.ui.road.facilities.intersection.task.utils.BeanUtils;
import com.szewec.ps.ui.road.facilities.intersection.task.utils.ViewUtils;
import com.szewec.ps.ui.road.facilities.intersection.task.views.IteamSlideLayout;
import com.szewec.ps.util.CommonUtils;
import com.szewec.ps.util.DateUtil;
import com.szewec.ps.util.GsonUtil;
import com.szewec.ps.util.LogUtil;
import com.szewec.ps.util.PhotoVideoUtil;
import com.szewec.ps.util.PreferincesContext;
import com.szewec.ps.util.RollUtil;
import com.szewec.ps.util.StringUtils;
import com.szewec.ps.util.TextViewUtil;
import com.szewec.ps.util.dialog.LoadingDialog;
import com.szewec.ps.util.dialog.SystemDialog;
import com.szewec.ps.util.imagepicker.GlideLoader;
import com.szewec.ps.util.imagepicker.ImagePicker;
import com.szewec.ps.util.imagepicker.activity.ImagePreActivity;
import com.szewec.ps.util.imagepicker.adapter.CustomPickerAdapterShowAndEdit;
import com.szewec.ps.util.imagepicker.data.MediaFile;
import com.szewec.ps.util.imagepicker.manager.SelectionManager;
import com.szewec.ps.util.imagepicker.utils.DataUtil;
import com.szewec.ps.util.okhttp.OkHttp;

import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import butterknife.ButterKnife;
import io.github.luizgrp.sectionedrecyclerviewadapter.SectionedRecyclerViewAdapter;

public class RoadIntersectionTaskActivity extends BaseMediaPickerActivity {
    private static final String TAG = "IntersectionTaskActivity";
    private ActivityIntersectionTaskBinding binding;

    private List<String> junctionTypeList = new ArrayList<>();  //交叉路口类型
    private List<String> coordinateTypeList = new ArrayList<>();    //信控类型
    private List<String> dextroversionCanalizationList = new ArrayList<>(); //右转渠化
    private List<String> junctionWidenList = new ArrayList<>(); //路口展宽
    private List<String> centerDividerList = new ArrayList<>();    //中央分隔带
    private List<String> roadsideDividerList = new ArrayList<>();  //路侧分隔带
    private List<String> trafficOrganizationTypeList = new ArrayList<>(); //交通组织方式
    private List<String> trafficGeometryList = new ArrayList<>();  //立交几何形状
    private List<String> centralIslandShapeList = new ArrayList<>();

    private List<RoadHierarchy> roadHierarchyList = new ArrayList<>();
    private RoadLevelDataAdapter roadLevelDataAdapter;

    private List<EntranceRoad> entranceRoadList = new ArrayList<>();
    private EntranceRoadAdapter entranceRoadAdapter;

    private IntersectionTask intersectionTask = new IntersectionTask();
    private GradeCrossing gradeCrossing = new GradeCrossing();
    private SolidCrossing solidCrossing = new SolidCrossing();
    private RoundaboutDetail roundaboutDetail = new RoundaboutDetail();
    private int junctionType = 0;

    private String junctionCoordinate;
    /**
     * 附件相关
     */
//    private ImagePicker imagePicker;
//    private String mFilePath;
//    private AlbumSection albumSection;
//    private final static AlbumFile upload = new AlbumFile();
//    private final List<AlbumFile> albumFileList = new ArrayList<>();
//    private SectionedRecyclerViewAdapter sectionedAdapter;
    // 照片上传数组
    private List<String> photoSketchUploadIdArr = new ArrayList<>();
    // 照片文件数组
    private ArrayList<MediaFile> photoSketchFileArr = new ArrayList<>();
    // 图片适配器
    private CustomPickerAdapterShowAndEdit photoSketchAdapter;
    // 移除的图片ID数组
    private List<String> deletePhotoIdArr = new ArrayList<>();
    private static final String SKETCH = "路口设施";

//    static {
//        upload.setAdd(true);
//    }

    private String flag = Constants.PRESENT_VALUE_FLAG.ADD;
    SurveyObjectModel surveyObjectModel;

    //用来上传的数据
    private Object obj;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_intersection_task);
        ButterKnife.bind(this);
        Bundle presentValue = getIntent().getExtras();
        if (presentValue != null) {
            PresentValue<SurveyObjectModel> value = (PresentValue<SurveyObjectModel>) presentValue.getSerializable(Constants.EXTRA_KEY.ROAD_INTERSECTION_TASK);
            flag = value.getFlag();
            surveyObjectModel = value.getT();
        }

        initTitleBar();

        initSelect();

        initInputView();
        initRecycleView();
//        initView();
//        initImagePicker();

        initData();
    }

    //加载标题
    private void initTitleBar() {
        binding.titleBar.setLeftLayoutVisibility(View.VISIBLE);
        binding.titleBar.setLeftLayoutClickListener(this::finish);
        binding.titleBar.setRightLayoutVisibility(View.VISIBLE);
        binding.titleBar.setRightTextVisibility(View.VISIBLE);
        binding.titleBar.setRightTextClickListener(v -> {
            if (!saveData()) {
                return;
            }
            switch (flag) {
                case Constants.PRESENT_VALUE_FLAG.ADD:
                    postData(null);
                    finish();
                    break;
                case Constants.PRESENT_VALUE_FLAG.EDIT:
                    putData();
                    this.finish();
                    break;
            }
        });
    }

    //加载下拉框的选项
    private void initSelect() {
        junctionTypeList = Arrays.asList(getResources().getStringArray(R.array.junction_type));
        coordinateTypeList = Arrays.asList(getResources().getStringArray(R.array.coordinate_type));
        dextroversionCanalizationList = Arrays.asList(getResources().getStringArray(R.array.dextroversion_canalization));
        junctionWidenList = Arrays.asList(getResources().getStringArray(R.array.boolean_array));
        centerDividerList = Arrays.asList(getResources().getStringArray(R.array.center_divider));
        roadsideDividerList = Arrays.asList(getResources().getStringArray(R.array.roadside_divider));
        trafficOrganizationTypeList = Arrays.asList(getResources().getStringArray(R.array.traffic_organization_type));
        trafficGeometryList = Arrays.asList(getResources().getStringArray(R.array.traffic_geometry));
        centralIslandShapeList = Arrays.asList(getResources().getStringArray(R.array.central_island_shape));
    }

    private void initData() {
        Map<String, Object> map = new HashMap<>();
        map.put("surveyObjectId", surveyObjectModel.getId());
        OkHttp.get("/tpms-plan-service/api/intersection-task", map, LoadingDialog.getInstance(this), result -> {
            ResponseData res = JSON.parseObject(result, ResponseData.class);
            if (res.getCode() == Constants.ResponseCode.SUCCESS) {
                LogUtil.i(TAG + "intersection-task=get====>", res.getData().toString());
                // 如果查询出来的结果为空，或者返回的JSON数组对象小于0 视为新增
                if (res.isDataEmpty()) {
                    flag = Constants.PRESENT_VALUE_FLAG.ADD;
                    return;
                }
                flag = Constants.PRESENT_VALUE_FLAG.EDIT;
                JSONObject json = JSON.parseArray(res.getData().toString()).getJSONObject(0);
                intersectionTask = JSON.toJavaObject(json, IntersectionTask.class);
                gradeCrossing = JSON.toJavaObject(json, GradeCrossing.class);
                solidCrossing = JSON.toJavaObject(json, SolidCrossing.class);
                roundaboutDetail = JSON.toJavaObject(json, RoundaboutDetail.class);
                binding.itJunctionName.setValue(intersectionTask.getJunctionName());
                junctionType = intersectionTask.getJunctionType() == null ? 1 : intersectionTask.getJunctionType();
                binding.itJunctionType.setValue(RoadEnums.JunctionType.getValueByKey(junctionType));
                junctionCoordinate = intersectionTask.getJunctionCoordinate();
                SelectedPoint point = JSON.parseObject(junctionCoordinate, SelectedPoint.class);

                binding.tvCoordinate.setValue(point.getxCoordinate(), point.getyCoordinate());
                binding.itImportRoadSize.setValue(intersectionTask.getImportRoadSize());
                roadHierarchyList = JSONArray.parseArray(intersectionTask.getRoadHierarchy(), RoadHierarchy.class);
                intersectionTask.setRoadHierarchies(roadHierarchyList);
                roadLevelDataAdapter.setDataList(roadHierarchyList);
                roadLevelDataAdapter.notifyDataSetChanged();
                dynamicLoadView(junctionType);
                setViewData();
                getEntranceRoadData();
                // 附件
                initViewFile();
//                BamToast.showText(this, test.getMsg(), true);
            } else {
                BamToast.showText(this, res.getMsg(), false);
            }
        });
    }

    private void getEntranceRoadData() {
        if (flag.equals(Constants.PRESENT_VALUE_FLAG.EDIT)) {
            Map<String, Object> map = new HashMap<>();
            map.put("intersectionTaskId", intersectionTask.getId());
            OkHttp.get("/tpms-plan-service/api/entrance-road", map, null, result -> {
                ResponseData res = JSON.parseObject(result, ResponseData.class);
                if (res.getCode() == Constants.ResponseCode.SUCCESS && !res.isDataEmpty()) {
                    entranceRoadList = JSONArray.parseArray(res.getData().toString(), EntranceRoad.class);
                    entranceRoadAdapter.setDataList(entranceRoadList);
                    entranceRoadAdapter.notifyDataSetChanged();
                    LogUtil.d(TAG + "entranceRoadList================>", entranceRoadList.get(0).getImportRoadNum());
                }
            });
        }
    }

    private void setViewData() {
        binding.itCoordinateType.setValue(RoadEnums.CoordinateType.getValueByKey(gradeCrossing.getCoordinateType()));
        binding.itDextroversionCanalization.setValue(RoadEnums.DextroversionCanalization.getValueByKey(gradeCrossing.getDextroversionCanalization()));
        binding.itJunctionWiden.setValue(gradeCrossing.getJunctionWiden() == null ? "" : junctionWidenList.get(gradeCrossing.getJunctionWiden()));
        binding.itCenterDivider.setValue(RoadEnums.CenterDivider.getValueByKey(gradeCrossing.getCenterDivider()));
        binding.itRoadsideDivider.setValue(RoadEnums.RoadsideDivider.getValueByKey(gradeCrossing.getRoadsideDivider()));
        binding.itTrafficOrganizationType.setValue(RoadEnums.TrafficOrganizationType.getValueByKey(solidCrossing.getTrafficOrganizationType()));
        binding.itTrafficGeometry.setValue(RoadEnums.TrafficGeometry.getValueByKey(solidCrossing.getTrafficGeometry()));
        binding.itTrafficRoadNum.setValue(solidCrossing.getTrafficRoadNum());
        binding.itTrafficCenterDivider.setValue(RoadEnums.CenterDivider.getValueByKey(solidCrossing.getCenterDivider()));
        binding.itCentralIslandShape.setValue(RoadEnums.CentralIslandShape.getValueByKey(roundaboutDetail.getCentralIslandShape()));

        BeanUtils.stripTrailingZeros(roundaboutDetail);
        roundaboutDetail.setCentralIslandRadius(roundaboutDetail.getCentralIslandRadius());
        binding.itCentralIslandRadius.setValue(roundaboutDetail.getCentralIslandRadius());
        binding.itRoundaboutLaneNum.setValue(roundaboutDetail.getRoundaboutLaneNum());
        binding.itRoundaboutLaneDirection.setValue(roundaboutDetail.getRoundaboutLaneDirection());
        binding.itRoundaboutLaneWidth.setValue(roundaboutDetail.getRoundaboutLaneWidth());
    }

    //加载数据
    private boolean saveData() {
//        if (StringUtils.isEmpty(roadFacilitiesTask.getId())) {
//            roadFacilitiesTask.setId(UUID.randomUUID().toString().replaceAll("-", "").toLowerCase());
//        }
        Integer importRoadSize = binding.itImportRoadSize.getIntValue();
//        junctionType = RoadEnums.JunctionType.getKeyByValue(binding.itJunctionType.getStringValue());
        if (junctionType == 0) {
            BamToast.showText(this, "请先选择交叉口类型", false);
            return false;
        } else if (importRoadSize == null || importRoadSize == 0) {
            BamToast.showText(this, "请先填写进口个数", false);
            return false;
        } else if (roadHierarchyList.isEmpty()) {
            BamToast.showText(this, "请先添加交叉口道路", false);
            return false;
        } else if (StringUtils.isEmpty(junctionCoordinate)) {
            BamToast.showText(this, "请先选择坐标信息", false);
            return false;
        }
        intersectionTask.setJunctionName(binding.itJunctionName.getStringValue());
        intersectionTask.setSurveyObjectId(surveyObjectModel.getId());
//        int junctionType = RoadEnums.JunctionType.getKeyByValue(binding.itJunctionName.getStringValue());
        intersectionTask.setJunctionType(junctionType);
        intersectionTask.setRoadHierarchies(roadHierarchyList);
        intersectionTask.setRoadHierarchy(GsonUtil.beanToString(roadHierarchyList));
        intersectionTask.setImportRoadSize(binding.itImportRoadSize.getIntValue());
        intersectionTask.setJunctionCoordinate(junctionCoordinate);
        // 添加/删除附件
        intersectionTask.setAddIds(photoSketchUploadIdArr);
        intersectionTask.setRemoveIds(deletePhotoIdArr);

        if (junctionType == RoadEnums.JunctionType.INTERCHANGE.getKey()) {
            BeanUtils.copyObj(intersectionTask, solidCrossing);
            solidCrossing.setTrafficOrganizationType(RoadEnums.TrafficOrganizationType.getKeyByValue(binding.itTrafficOrganizationType.getStringValue()));
            solidCrossing.setTrafficGeometry(CommonUtils.getDictKeyForOne(trafficGeometryList, binding.itTrafficGeometry.getStringValue()));
            solidCrossing.setTrafficRoadNum(binding.itTrafficRoadNum.getIntValue());
            solidCrossing.setCenterDivider(CommonUtils.getDictKeyForOne(centerDividerList, binding.itTrafficCenterDivider.getStringValue()));
            obj = solidCrossing;
        } else {
            BeanUtils.copyObj(intersectionTask, gradeCrossing);
            gradeCrossing.setCoordinateType(CommonUtils.getDictKeyForOne(coordinateTypeList, binding.itCoordinateType.getStringValue()));
            gradeCrossing.setDextroversionCanalization(CommonUtils.getDictKeyForOne(dextroversionCanalizationList, binding.itDextroversionCanalization.getStringValue()));
            gradeCrossing.setJunctionWiden(CommonUtils.getDictKey(junctionWidenList, binding.itJunctionWiden.getStringValue()));
            gradeCrossing.setCenterDivider(CommonUtils.getDictKeyForOne(centerDividerList, binding.itCenterDivider.getStringValue()));
            gradeCrossing.setRoadsideDivider(CommonUtils.getDictKeyForOne(roadsideDividerList, binding.itRoadsideDivider.getStringValue()));
            obj = gradeCrossing;
            if (junctionType == RoadEnums.JunctionType.ROUNDABOUT.getKey()) {
                BeanUtils.copyObj(gradeCrossing, roundaboutDetail);
                roundaboutDetail.setCentralIslandShape(CommonUtils.getDictKeyForOne(centralIslandShapeList, binding.itCentralIslandShape.getStringValue()));
                roundaboutDetail.setCentralIslandRadius(binding.itCentralIslandRadius.getBigDecimalValue());
                roundaboutDetail.setRoundaboutLaneNum(binding.itRoundaboutLaneNum.getIntValue());
                roundaboutDetail.setRoundaboutLaneDirection(binding.itRoundaboutLaneDirection.getStringValue());
                roundaboutDetail.setRoundaboutLaneWidth(binding.itRoundaboutLaneWidth.getBigDecimalValue());
                obj = roundaboutDetail;
            }
        }
        return true;
    }

    //新增数据
    private void postData(CallBackInterface callBackInterface) {
        OkHttp.post("/tpms-plan-service/api/intersection-task/", obj, result -> {
            ResponseData test = JSON.parseObject(result, ResponseData.class);
            if (test.getCode() == 10000) {
                if (callBackInterface != null) {
                    callBackInterface.customizedFun();
                }
                intersectionTask = JSON.parseObject(test.getData().toString(), IntersectionTask.class);
                flag = Constants.PRESENT_VALUE_FLAG.EDIT;
                BamToast.showText(this, test.getMsg(), true);
            } else {
                BamToast.showText(this, test.getMsg(), false);
            }
            LogUtil.i(TAG + "post=====>", result);
        });
    }

    //修改数据
    private void putData() {
        OkHttp.put("/tpms-plan-service/api/intersection-task/", obj, result -> {
            ResponseData test = JSON.parseObject(result, ResponseData.class);
            BamToast.showText(this, test.getMsg(), test.getCode() == 10000);
            LogUtil.i(TAG + "intersection-task=put====>", result);
        });
    }

    //监听滑动
    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            if (sets.size() > 0) {
                for (IteamSlideLayout s : sets) {
                    if (ViewUtils.isClickNotInView(s.getMenuView(), event)) {
                        s.close();
                        return true;
                    }
                }
            }
        }
        return ViewUtils.dispatchTouchEvent(this, event);
//        // 必不可少，否则所有的组件都不会有TouchEvent了
//        return getWindow().superDispatchTouchEvent(event) || onTouchEvent(event);
    }

    //根据选择的道路类型显示不同的组件
    private void showSelectJunctionType() {
        int temp = junctionType;
        RollUtil.alertBottomWheelOption(this, junctionTypeList, binding.itJunctionType.getSelectTextView(), (view, index) -> {
            junctionType = index + 1;
            dynamicLoadView(temp);
            binding.itJunctionType.setValue(junctionTypeList.get(index));
        });
    }

    //根据选择的道路类型加载不同视图
    private void dynamicLoadView(int preJunctionType) {
        if (junctionType == RoadEnums.JunctionType.INTERCHANGE.getKey()) {
            binding.gradeCrossing.setVisibility(View.GONE);
            binding.solidCrossing.setVisibility(View.VISIBLE);
            binding.roundaboutDetail.setVisibility(View.GONE);
            if (preJunctionType != junctionType) {
                roadHierarchyList.clear();
                roadLevelDataAdapter.setDataList(roadHierarchyList);
                roadLevelDataAdapter.notifyDataSetChanged();
            }
        } else if (junctionType == RoadEnums.JunctionType.ROUNDABOUT.getKey()) {
            binding.solidCrossing.setVisibility(View.GONE);
            binding.gradeCrossing.setVisibility(View.VISIBLE);
            binding.roundaboutDetail.setVisibility(View.VISIBLE);
        } else {
            binding.solidCrossing.setVisibility(View.GONE);
            binding.gradeCrossing.setVisibility(View.VISIBLE);
            binding.roundaboutDetail.setVisibility(View.GONE);
        }
        binding.tvaImportRoadNum.setVisibility(View.VISIBLE);
    }

    //加载下拉框
    private void initInputView() {
        binding.itJunctionName.switchoverMode(false);
//        switchMode(binding.gradeCrossing, false);
        binding.itJunctionType.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            if (binding.itJunctionType.getStringValue() == null || binding.itJunctionType.getStringValue().equals("")) {
                showSelectJunctionType();
            } else {
                CommonDialog commonDialog = new CommonDialog(this);
                commonDialog.setTitle(this.getResources().getString(R.string.confirm_hint));
                commonDialog.setContent("重新选择类型将导致之前数据丢失，是否继续？");
                commonDialog.setCancel("取消");
                commonDialog.setEnsure("继续");
                commonDialog.setOnEnsureClickListener(v1 -> {
                    resetInput();

                    showSelectJunctionType();
                    commonDialog.dismiss();
                });
                commonDialog.setOnCancelClickListener((view) -> commonDialog.dismiss());
                commonDialog.show();
            }
        });

        binding.itCoordinateType.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            RollUtil.alertBottomWheelOption(this, coordinateTypeList, binding.itCoordinateType.getSelectTextView(), (view, index) ->
                    binding.itCoordinateType.setValue(coordinateTypeList.get(index)));
        });
        binding.itCoordinateType.setValue("非信控交叉口");

        binding.itDextroversionCanalization.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            RollUtil.alertBottomWheelOption(this, dextroversionCanalizationList, binding.itDextroversionCanalization.getSelectTextView(), (view, index) ->
                    binding.itDextroversionCanalization.setValue(dextroversionCanalizationList.get(index)));
        });

        binding.itJunctionWiden.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            RollUtil.alertBottomWheelOption(this, junctionWidenList, binding.itJunctionWiden.getSelectTextView(), (view, index) ->
                    binding.itJunctionWiden.setValue(junctionWidenList.get(index)));
        });

        binding.itCenterDivider.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            RollUtil.alertBottomWheelOption(this, centerDividerList, binding.itCenterDivider.getSelectTextView(), (view, index) ->
                    binding.itCenterDivider.setValue(centerDividerList.get(index)));
        });

        binding.itRoadsideDivider.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            RollUtil.alertBottomWheelOption(this, roadsideDividerList, binding.itRoadsideDivider.getSelectTextView(), (view, index) ->
                    binding.itRoadsideDivider.setValue(roadsideDividerList.get(index)));
        });

        binding.itTrafficOrganizationType.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            RollUtil.alertBottomWheelOption(this, trafficOrganizationTypeList, binding.itTrafficOrganizationType.getSelectTextView(), (view, index) ->
                    binding.itTrafficOrganizationType.setValue(trafficOrganizationTypeList.get(index)));
        });
        binding.itTrafficOrganizationType.setValue("完全互通");

        binding.itTrafficGeometry.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            RollUtil.alertBottomWheelOption(this, trafficGeometryList, binding.itTrafficGeometry.getSelectTextView(), (view, index) ->
                    binding.itTrafficGeometry.setValue(trafficGeometryList.get(index)));
        });

        binding.itTrafficCenterDivider.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            RollUtil.alertBottomWheelOption(this, centerDividerList, binding.itTrafficCenterDivider.getSelectTextView(), (view, index) ->
                    binding.itTrafficCenterDivider.setValue(centerDividerList.get(index)));
        });

//        binding.itTrafficRoadNum.switchoverMode(false);

        binding.tvaAddRoadLevel.setIronClickListener(v -> {
            Integer trafficRoadNum = binding.itTrafficRoadNum.getIntValue();
            if (junctionType == 0) {
                BamToast.showText(this, "请先选择交叉口类型", false);
                return;
            } else if (junctionType == RoadEnums.JunctionType.INTERCHANGE.getKey() && (trafficRoadNum == null || trafficRoadNum == 0)) {
                BamToast.showText(this, "请先填写相交道路数", false);
                return;
            }
            Intent intent = new Intent(this, RoadHierarchyAddActivity.class);
            Map<String, Object> map = new HashMap<>();
            map.put("junctionType", junctionType);
            map.put("trafficRoadNum", trafficRoadNum);
            PresentValue<Map<String, Object>> presentValue = new PresentValue<>(Constants.PRESENT_VALUE_FLAG.ADD, map);
            intent.putExtra(Constants.EXTRA_KEY.ROAD_LEVEL, presentValue);

            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), this::addRoadLevelResult).launch(intent);
        });

//        binding.lRecyclerViewMainStructuralPlane.setOn

        binding.itCentralIslandShape.setSelectTypeClickListener(v -> {
            TextViewUtil.closeKeyboard(this);
            RollUtil.alertBottomWheelOption(this, centralIslandShapeList, binding.itCentralIslandShape.getSelectTextView(), (view, index) ->
                    binding.itCentralIslandShape.setValue(centralIslandShapeList.get(index)));
        });

        binding.itRoundaboutLaneNum.setTextChangeListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                try {
                    StringBuilder roundaboutLaneDirection = new StringBuilder();
                    if (s.toString().equals("")) {
                        return;
                    } else if (Integer.parseInt(s.toString()) == 0 || Integer.parseInt(s.toString()) > 4) {
                        BamToast.showText(RoadIntersectionTaskActivity.this, "请输入1到4之间的数", false);
                    }
                    for (int i = 0; i < Integer.parseInt(s.toString()) - 1; i++) {
                        roundaboutLaneDirection.append("直行、");
                    }
                    roundaboutLaneDirection.append("右转");
                    binding.itRoundaboutLaneDirection.setValue(roundaboutLaneDirection);
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                    BamToast.showText(RoadIntersectionTaskActivity.this, R.string.number_format_exception, false);
                }
            }
        });

        binding.itRoundaboutLaneDirection.switchoverMode(false);

        binding.tvaImportRoadNum.setIronClickListener(v -> {
            //将数据存入对象
            if (!saveData()) {
                return;
            }
            //新增数据
            switch (flag) {
                //如果当前是新增则先让用户保存数据
                case Constants.PRESENT_VALUE_FLAG.ADD:
                    CommonUtils.showIsSave(RoadIntersectionTaskActivity.this, () -> postData(this::addImportRoad));
                    break;
                case Constants.PRESENT_VALUE_FLAG.EDIT:
                    addImportRoad();
                    break;
            }
        });
    }

    //跳转添加进口道数据
    private void addImportRoad() {
        Intent intent = new Intent(this, EntranceRoadActivity.class);
        Map<String, Object> map = new HashMap<>();
        map.put("intersectionTask", intersectionTask);
        PresentValue<Map<String, Object>> presentValue = new PresentValue<>(Constants.PRESENT_VALUE_FLAG.ADD, map);
        intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);

        registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), this::entranceRoadResult).launch(intent);
    }

    /**
     * 清空页面输入框
     */
    private void resetInput() {
/*        if (linearLayout != null) {
            for (int i = 0; i < linearLayout.getChildCount(); i++) {
                View view = linearLayout.getChildAt(i);
                if (view instanceof InputItem) {
                    ((InputItem) view).setValue(null);
                }
            }
        }*/
        solidCrossing = new SolidCrossing();
        gradeCrossing = new GradeCrossing();
        roundaboutDetail = new RoundaboutDetail();
        setViewData();
    }

    /**
     * 道路等级添加或修改的回调
     *
     * @param result
     */
    private void addRoadLevelResult(ActivityResult result) {
        if (result.getData() != null) {
            LogUtil.i(TAG, "getData=====>" + result.getData().getSerializableExtra(Constants.EXTRA_KEY.ROAD_LEVEL));
            PresentValue<RoadHierarchy> value = (PresentValue<RoadHierarchy>) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ROAD_LEVEL);
            if (value != null) {
                RoadHierarchy roadHierarchy = value.getT();
                if (value.getFlag().equals(Constants.PRESENT_VALUE_FLAG.ADD)) {
                    roadHierarchyList.add(roadHierarchy);
                } else if (value.getFlag().equals(Constants.PRESENT_VALUE_FLAG.EDIT)) {
                    if (roadHierarchy.getPosition() == null || roadHierarchy.getPosition() < 0) {
                        return;
                    }
                    roadHierarchyList.set(roadHierarchy.getPosition(), roadHierarchy);
                }
                roadLevelDataAdapter.setDataList(roadHierarchyList);
                roadLevelDataAdapter.notifyDataSetChanged();
                StringBuilder junctionName = new StringBuilder();
                for (int i = 0; i < roadHierarchyList.size(); i++) {
                    if (i == 0) {
                        junctionName = new StringBuilder(roadHierarchyList.get(i).getRoadName());
                    } else {
                        junctionName.append("、").append(roadHierarchyList.get(i).getRoadName());
                    }
                }
                binding.itJunctionName.setValue(junctionName);
            }
        }
    }

    /**
     * 进口道添加或修改的回调
     *
     * @param result
     */
    private void entranceRoadResult(ActivityResult result) {
        if (result.getData() != null) {
            LogUtil.i(TAG, "getData=====>" + result.getData().getSerializableExtra(Constants.EXTRA_KEY.ROAD_LEVEL));
            PresentValue<EntranceRoad> value = (PresentValue<EntranceRoad>) result.getData().getSerializableExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD);

            if (value != null) {
                EntranceRoad valueT = value.getT();
                if (value.getFlag().equals(Constants.RESULT_FLAG.INSERT_OR_UPDATE)) {
                    if (valueT.getPosition() == null || valueT.getPosition() < 0) {
                        entranceRoadList.add(valueT);
                    } else {
                        entranceRoadList.set(valueT.getPosition(), valueT);
                    }
                } else if (value.getFlag().equals(Constants.RESULT_FLAG.DELETE)) {
                    entranceRoadList.remove(valueT.getPosition().intValue());
                }
                entranceRoadAdapter.setDataList(entranceRoadList);
                entranceRoadAdapter.notifyDataSetChanged();
            }
        }
    }

/*    @OnClick(R.id.tv_coordinate)
    public void onViewClicked(View view) {
        if (view.getId() == R.id.tv_coordinate) {
            Intent intent = new Intent(this, SelectCoordinatesActivity.class);
            PresentValue<String> presentValue = new PresentValue<>(Constants.SELECT_COOR_FLAG.SELECT_COOR, null);
            intent.putExtra(Constants.EXTRA_KEY.SELECT_COOR, presentValue);
            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), v -> {
                if (v.getData() != null) {
                    LogUtil.i(TAG, "v=====>" + v);
                    LogUtil.i(TAG, "getData=====>" + v.getData().getStringExtra(Constants.EXTRA_KEY.SELECT_COOR));

                    JSONArray json = JSONArray.parseArray(v.getData().getStringExtra(Constants.EXTRA_KEY.SELECT_COOR));
                    if (ListUtil.isEmpty(json) || (ListUtil.isNotEmpty(json) && json.size() > 1)) {
                        BamToast.showText(this, "请选择一个点！", false);
                        return;
                    }
                    junctionCoordinate = json.getJSONObject(0).toString();
//                        junction_coordinate = json.getJSONObject(0).getString("latitude") + "," + json.getJSONObject(0).getString("longitude");
//                    binding.tvCoordinate.setValue("已选择");
                }
            }).launch(intent);
        }
    }*/

//    //加载部分视图
//    private void initView() {
//        //附件
//        albumSection.setEdit(true);
//        albumFileList.add(upload);
//        sectionedAdapter.notifyDataSetChanged();
//    }

    //加载网格视图
    private void initRecycleView() {
        //附件
/*        albumSection.setEdit(true);
        albumFileList.add(upload);
        sectionedAdapter.notifyDataSetChanged();*/

        roadLevelDataAdapter = new RoadLevelDataAdapter(this);
        roadLevelDataAdapter.setDataList(roadHierarchyList);
//        binding.lRecyclerViewMainStructuralPlane.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
        binding.lRecyclerViewMainStructuralPlane.setAdapter(new LRecyclerViewAdapter(roadLevelDataAdapter));
        binding.lRecyclerViewMainStructuralPlane.setLayoutManager(new LinearLayoutManager(this));
        binding.lRecyclerViewMainStructuralPlane.setLoadMoreEnabled(false);
        binding.lRecyclerViewMainStructuralPlane.setPullRefreshEnabled(false);

        entranceRoadAdapter = new EntranceRoadAdapter(this);
        entranceRoadAdapter.setDataList(entranceRoadList);
        binding.lrvImportRoadNum.setAdapter(new LRecyclerViewAdapter(entranceRoadAdapter));
        binding.lrvImportRoadNum.setLayoutManager(new LinearLayoutManager(this));
        binding.lrvImportRoadNum.setLoadMoreEnabled(false);
        binding.lrvImportRoadNum.setPullRefreshEnabled(false);

//        sectionedAdapter = new SectionedRecyclerViewAdapter();
//        RecyclerView recyclerView = binding.rvOfflineAlbum;
//        GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 4);
//        gridLayoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
//            @Override
//            public int getSpanSize(final int position) {
//                if (sectionedAdapter.getSectionItemViewType(position) == SectionedRecyclerViewAdapter.VIEW_TYPE_HEADER) {
//                    return Constants.SPAN_COUNT;
//                }
//                if (sectionedAdapter.getSectionItemViewType(position) == SectionedRecyclerViewAdapter.VIEW_TYPE_FOOTER) {
//                    return Constants.SPAN_COUNT;
//                }
//                return 1;
//            }
//        });
//        ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
//        recyclerView.setLayoutManager(gridLayoutManager);
//        recyclerView.setAdapter(sectionedAdapter);
//
//        albumSection = new AlbumSection(SKETCH, albumFileList, this, true);
//        albumSection.setHasFooter(false);
//        albumSection.setHasHeader(false);
//        sectionedAdapter.addSection(SKETCH, albumSection);
    }

//    /**
//     * 初始化图片选择器
//     */
//    private void initImagePicker() {
//        imagePicker = ImagePicker.getInstance();
//        imagePicker.setTitle("")//设置标题
//                .showCamera(false)//设置是否显示拍照按钮
//                .showImage(true)//设置是否展示图片
//                .showVideo(true)//设置是否展示视频
//                .setSingleType(false)//设置图片视频不能同时选择
//                .setMaxCount(999)//设置最大选择图片数目(默认为1，单选)
//                .setImageLoader(new GlideLoader());//设置自定义图片加载器
//    }
//
//    /**
//     * 上传照片按钮事件
//     */
//    private void addPhotoAction(int fileType) {
//        List<String> names = new ArrayList<>();
//        names.add("拍照");
//        names.add("从相册选择");
//        SystemDialog.showSelectDialog(this, (parent, view, position, id) -> {
//            switch (position) {
//                case 0:
//                    // 直接调起相机
//                    mFilePath = PhotoVideoUtil.showCamera(this, Constants.REQUEST_CODE.FIELD_SURVEY_CAPTURE);
//                    break;
//                case 1://从相册选择
//                    imagePicker.start(this, Constants.REQUEST_CODE.FIELD_SURVEY_LOCAL_MEDIA);//REQEST_SELECT_IMAGES_CODE为Intent调用的requestCode
//                    break;
//                default:
//                    break;
//            }
//
//        }, names);
//    }

    // 设置照片
    private void initViewFile() {
        // 初始化照片适配器
        photoSketchAdapter = initTypeMediaRecyclerView(photoSketchUploadIdArr, photoSketchFileArr,
                binding.photoSketchSketchRV, true, false, true, deletePhotoIdArr);

        // 先根据fileId查询附件数据
        if (!CollectionUtils.isEmpty(intersectionTask.getAddIds())) {
            requestFilesByIds(intersectionTask.getAddIds(), this::initAdapterData);
        }
        // 根据业务ID查询附件信息
        else if (StringUtils.isNotEmpty(intersectionTask.getId())) {
            requestFiles(FileUpload.RoadInvestigationFileBizTypeEnum.ROAD_INTERSECTION_TASK_FILE_BIZ_TYPE, intersectionTask.getId(), this::initAdapterData);
        }
    }

    // 往照片适配器里面设置图片显示
    private void initAdapterData(List<MediaFile> mediaFileList) {
        if (CollectionUtils.isEmpty(mediaFileList)) {
            return;
        }
        photoSketchUploadIdArr.clear();
        photoSketchFileArr.clear();
        // 添加到文件数组
        photoSketchFileArr.addAll(mediaFileList);
        for (MediaFile mediaFile : photoSketchFileArr) {
            photoSketchUploadIdArr.add(mediaFile.getId());
        }
        // 设置适配器数据源
        photoSketchAdapter.setmMediaFileList(mediaFileList);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
//        System.out.println(mFilePath);
        super.onActivityResult(requestCode, resultCode, data);
        switch (resultCode) {
            case RESULT_OK:
//                //通知媒体库刷新(刷新相册图库及时显示)
//                sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + mFilePath)));
//                switch (requestCode) {
//                    //拍照返回
//                    case Constants.REQUEST_CODE.FIELD_SURVEY_CAPTURE:
//                        System.out.println("xx:" + mFilePath);
////                    WatermarkUtil.addWaterMark(mFilePath,false);
//                        saveFile(Constants.FileType.PHOTO);
//                        break;
//                    case Constants.REQUEST_CODE.FIELD_SURVEY_LOCAL_MEDIA:
//                        List<MediaFile> files = SelectionManager.getInstance().getmSelectedMediaFileList();
//                        for (MediaFile mediaFile : files) {
//                            mFilePath = mediaFile.getPath();
//                            if (mFilePath.endsWith("mp4")) {
//                                saveFile(Constants.FileType.VIDEO);
//                            } else if (mFilePath.endsWith("jpg")) {
//                                //复制,加水印
////                            mFilePath = WatermarkUtil.addWaterMark(mFilePath,true);
//                                saveFile(Constants.FileType.PHOTO);
//                            }
//                        }
//                        break;
//                }
                //拍照返回，或者视频录制返回
                if (isAdapterImagePickerResult(requestCode, photoSketchAdapter)) {
                    ArrayList<MediaFile> mediaFileList = getMediaFileListWhenOnActivityResult(requestCode, data, photoSketchAdapter);
                    saveFileAndRefreshAdapter(mediaFileList, photoSketchUploadIdArr, photoSketchAdapter,
                            FileUpload.RoadInvestigationFileBizTypeEnum.ROAD_INTERSECTION_TASK_FILE_BIZ_TYPE);
                }
                break;
            case Constants.RESULT_CODE.SELECTED_POINT:
                if (data != null) {
                    SelectedPoint point = (SelectedPoint) data.getSerializableExtra(Constants.EXTRA_KEY.MAP_CENTER_POINT);
                    if (point != null) {
                        binding.tvCoordinate.setValue(point.getxCoordinate(), point.getyCoordinate());
//                        binding.tvCoordinate.setValue(point.getAddress());
                        junctionCoordinate = JSON.toJSONString(point);
                    }
                }
        }
    }

    /**
     * 保存拍照的单个文件
     */
    //TODO 附件名称命名规则
//    private void saveFile(int fileType) {
//        AlbumFile albumFile = new AlbumFile();
//        albumFile.setAdd(false);
//        switch (fileType) {
//            case Constants.FileType.PHOTO:
//                albumFile.setType(0);
//                albumFile.setDuration(0);
//                break;
//            case Constants.FileType.VIDEO:
//                albumFile.setType(1);
//                albumFile.setDuration(PhotoVideoUtil.getDuration(mFilePath));
//                break;
//        }
//        albumFile.setPath(mFilePath);
//        albumFile.setFileType(PhotoVideoUtil.getSuffix(mFilePath));
//        albumFile.setId(CommonUtils.generateId());
//        albumFile.setSyncStatus(PreferincesContext.SYNCSTATUS_ADD);
//
//        albumFile.setFileName(SKETCH + "_" + DateUtil.getCurDateInString("yyyy-MM-dd hh:mm:ss"));
//        albumFileList.add(albumFileList.size() - 1, albumFile);//倒数第二个
//        sectionedAdapter.notifyDataSetChanged();
//    }
//
//    @Override
//    public void onItemViewClicked(@NonNull String sectionTitle, int itemAdapterPosition, AlbumFile albumFile) {
//        int fileType = 0;
//        if (albumFile.isAdd()) {
//            addPhotoAction(fileType);
//        } else {
//            if (albumFile.getType() == Constants.FileType.RECORD_SOUND) {
//                PhotoVideoUtil.playRecordSound(this, albumFile.getPath());
//            } else {
//                int position = sectionedAdapter.getPositionInSection(itemAdapterPosition);
//                List<AlbumFile> previewList;
//                String currentId = null;
//                if (SKETCH.equals(sectionTitle)) {
//                    previewList = new ArrayList<>(albumFileList);
//                    currentId = albumFileList.get(position).getId();
//                } else {
//                    previewList = new ArrayList<>();
//                }
//
//                PhotoVideoUtil.removeFileIsAddInList(previewList);
//                List<MediaFile> mediaFileList = PhotoVideoUtil.convert2MediaFile(previewList);
//                DataUtil.getInstance().setMediaData(mediaFileList);
//                Intent intent = new Intent(this, ImagePreActivity.class);
//                //删除录音和add后下标发生了变化,处理新下标
//                int newPosition = 0;
//                for (int i = 0; i < previewList.size(); i++) {
//                    if (previewList.get(i).getId().equals(currentId)) {
//                        newPosition = i;
//                    }
//                }
//                intent.putExtra(ImagePreActivity.IMAGE_POSITION, newPosition);
//                startActivityForResult(intent, Constants.REQUEST_CODE.FIELD_SURVEY_PREVIEW);
//            }
//        }
//    }
//
//    @Override
//    public void onItemDeleteClicked(@NonNull String sectionTitle, int itemAdapterPosition) {
//        int position = sectionedAdapter.getPositionInSection(itemAdapterPosition);
//        if (SKETCH.equals(sectionTitle)) {
//            //                albumFileBaseManager.delete(albumFileList.get(position));
//            albumFileList.remove(position);
//        }
//        sectionedAdapter.notifyDataSetChanged();
//    }

    private Set<IteamSlideLayout> sets = new HashSet<>();

    private void editRoadLevel(RoadHierarchy model, String type) {
        //将数据存入对象
        if (type.equals(Consts.OperationType.EDIT)) {
            Integer trafficRoadNum = binding.itTrafficRoadNum.getIntValue();
            Intent intent = new Intent(this, RoadHierarchyAddActivity.class);
            Map<String, Object> map = new HashMap<>();
            map.put("junctionType", junctionType);
            map.put("roadLevel", model);
            map.put("trafficRoadNum", trafficRoadNum);
            PresentValue<Map<String, Object>> presentValue = new PresentValue<>(Constants.PRESENT_VALUE_FLAG.EDIT, map);
            intent.putExtra(Constants.EXTRA_KEY.ROAD_LEVEL, presentValue);

            registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), this::addRoadLevelResult).launch(intent);
        } else if (type.equals(Consts.OperationType.DELETE)) {
            CommonUtils.doubleBtnDialog(this, () -> {
                roadHierarchyList.remove(model);
                roadLevelDataAdapter.setDataList(roadHierarchyList);
                roadLevelDataAdapter.notifyDataSetChanged();
            });
        }
    }

    //自定义适配器
    private class RoadLevelDataAdapter extends ListBaseAdapter<RoadHierarchy> {

        public RoadLevelDataAdapter(Context context) {
            super(context);
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_road_name_and_level;
        }

        @SuppressLint("SetTextI18n")
        @Override
        public void onBindItemHolder(SuperViewHolder holder, int position) {
            TextView title = holder.getView(R.id.tv_common_title);
            View content = holder.getView(R.id.content);
            TextView level = holder.getView(R.id.tv_level);
            TextView delete = holder.getView(R.id.tv_delete);
            RoadHierarchy model = mDataList.get(position);
            title.setText(model.getRoadName());
            level.setText(model.getRoadLevel());
            model.setPosition(position);
            IteamSlideLayout layout = (IteamSlideLayout) holder.itemView;
            layout.setOnStateChangeListener(new MyOnStateChangeListener());

            content.setOnClickListener(v -> editRoadLevel(model, Consts.OperationType.EDIT));
            delete.setOnClickListener(v -> editRoadLevel(model, Consts.OperationType.DELETE));


            //行点击监听事件
//            holder.itemView.setOnClickListener(view -> {
//                Intent intent = new Intent(this, MainStructuralPlaneActivity.class);
//                PresentValue<MainStructuralPlane> presentValue = new PresentValue<>(Constants.PRESENT_VALUE_FLAG.VIEW, model);
//                intent.putExtra(Constants.EXTRA_KEY.MAIN_STRUCTUREA_PLANE, presentValue);
//                startActivityForResult(intent, Constants.REQUEST_CODE.MAIN_STRUCTUREA_PLANE);
//            });
        }

        @Override
        public int getItemCount() {
            return super.getItemCount();
        }
    }

    //实现删除按钮滑动状图改变监听事件，可以灵活存储当前打开的是哪一个，以便后面的优化
    private class MyOnStateChangeListener implements IteamSlideLayout.OnStateChangeListener {
        public IteamSlideLayout slideLayout = null;

        @Override
        public void onOpen(IteamSlideLayout layout) {
            slideLayout = layout;
            if (sets.size() > 0) {
                for (IteamSlideLayout s : sets) {
                    s.close();
                }
            }
            sets.add(layout);
        }

        @Override
        public void onMove(IteamSlideLayout layout) {
        }

        @Override
        public void onClose(IteamSlideLayout layout) {
            if (sets.size() > 0) {
                sets.remove(layout);
            }
            if (slideLayout == layout) {
                slideLayout = null;
            }
        }
    }

    private class EntranceRoadAdapter extends ListBaseAdapter<EntranceRoad> {

        public EntranceRoadAdapter(Context context) {
            super(context);
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_common_string;
        }

        @Override
        public void onBindItemHolder(SuperViewHolder holder, int position) {
            TextView title = holder.getView(R.id.tv_common_title);
            title.setText(mDataList.get(position).getImportRoadNum());
            title.setTextColor(0XFF888888);
            mDataList.get(position).setPosition(position);
            holder.itemView.setOnClickListener(v -> {
                if (!saveData()) {
                    return;
                }
                Intent intent = new Intent(RoadIntersectionTaskActivity.this, EntranceRoadActivity.class);
                Map<String, Object> map = new HashMap<>();
//                map.put("junctionType", junctionType);
//                map.put("roadLevelList", roadLevelList);
//                Integer importRoadSize = binding.itImportRoadSize.getIntValue();
//                map.put("importRoadSize", importRoadSize);
                map.put("entranceRoad", mDataList.get(position));
                map.put("intersectionTask", intersectionTask);
                PresentValue<Map<String, Object>> presentValue = new PresentValue<>(Constants.PRESENT_VALUE_FLAG.EDIT, map);
                intent.putExtra(Constants.EXTRA_KEY.ENTRANCE_ROAD, presentValue);

                registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), RoadIntersectionTaskActivity.this::entranceRoadResult).launch(intent);
            });
        }
    }
}